package com.twu.biblioteca;

/**
 * Created by sharan on 14/6/14.
 */
public class Movie {

    private String name;
    private int year;
    private String director;
    private double rate;
    private boolean issued;
    private String checkedoutUser;


    Movie(String name, int year, String director, double rate) {

        this.name = name;
        this.year = year;
        this.director = director;
        this.rate = rate;
        this.issued = false;
    }

    public String getName() {

        return this.name;
    }

    public int getYear() {

        return this.year;
    }

    public String getDirector() {

        return this.director;
    }

    public double getRate() {

        return this.rate;
    }

    public void setIssued() {

        this.issued = true;
    }

    public void setNotIssued() {

        this.issued = false;
    }

    public boolean getIssueStatus() {

        return this.issued;
    }

    public void setCheckedoutUser(String checkedoutUser) {

        this.checkedoutUser = checkedoutUser;
    }

    public String getCheckedoutUser() {

        return this.checkedoutUser;
    }

    @Override
    public boolean equals(Object movie){

        if(movie instanceof Movie){

            if(this.getName().equals(((Movie) movie).getName())){
                if(this.getDirector().equals(((Movie)movie).getDirector())){
                    if(this.getYear() == ((Movie)movie).getYear()){
                        return true;
                    }
                }
            }
        }
        return false;
    }

    @Override
    public String toString(){

        return this.getName() + this.getDirector() + this.getYear();
    }
}
